#!/bin/bash

# This is the default initialize file required in every module
# we define the variable friendly _D_MODULE_LOADED_NAME which
# is used by the module library to identify this module to 
# the program loading it.
#
# We also need to define our init function.  Each function in a 
# module which we want exported to the main program needs to be 
# in the format of _d_${_D_MODULE_LOADED_NAME}_<whatever>
# otherwise we won't be able to resolve it in the main program.

# what is the variable friendly name of this module
export _D_MODULE_LOADED_NAME="bootstrap"

# Our default initialization function that is called when the
# module is loaded.
#
# The path to the module is always passed as $1 to the init
# function.
#
_d_bootstrap_init() {
	_d_bootstrap_module_name=${_D_MODULE_LOADED_NAME}
	export _d_bootstrap_module_name
	_d_bootstrap_path=$1
	_d_bootstrap_conf=$2
	if [ ! -d "${_d_bootstrap_path}" ]; then
		return 1
	fi

	_d_bootstrap_lib="${_d_bootstrap_path}/lib"

	# save path for later use
	export _d_bootstrap_path
	export _d_bootstrap_conf
	export _d_bootstrap_lib

	# pull in main module
	. ${_d_bootstrap_path}/main 

	return 0
}

